<?php namespace Phpcmf\Controllers\Member;

class Woquan extends \Phpcmf\Member\Module
{

	// 圈子列表
	public function index() {

		$meta_title = '我的圈子';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('woquan.html');
	}
	// 圈帖子列表
	public function quantie() {
	
		$meta_title = '我的圈帖';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('quantie.html');
	}
	// 圈帖收藏
	public function shoucang() {
	
		$meta_title = '我的收藏';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('shoucang.html');
	}
	// 圈帖点赞
	public function zan() {
	
		$meta_title = '我的点赞';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('zan.html');
	}
	// 圈帖评论
	public function pinglun() {
	
		$meta_title = '我的评论';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('pinglun.html');
	}
	// 通知
	public function tongzhi() {
	
		$meta_title = '我的通知';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('tongzhi.html');
	}
	// 钱包
	public function qianbao() {
	
		$meta_title = '我的钱包';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('qianbao.html');
	}
	// 钱包收入
	public function qianbaoshouru() {
	
		$meta_title = '我的钱包收入';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('qianbao-shouru.html');
	}
	// 钱包支出
	public function qianbaozhichu() {
	
		$meta_title = '我的钱包支出';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('qianbao-zhichu.html');
	}
	// 钱包转账
	public function qianbaozhuan() {
	
		$meta_title = '我的钱包转账';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('qianbao-zhuan.html');
	}
	// 钱包提现
	public function qianbaotixian() {
	
		$meta_title = '我的钱包提现';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('qianbao-tixian.html');
	}
	// 余额判断
	public function yuepanduan() {
	    $yue = (int)\Phpcmf\Service::L('input')->get('yue');
		$shengyu = $this->member['money']-$yue;
		if($yue > $this->member['money']){
			$rt=[
				'code'=>0,
			    'msg'=> '余额不够了',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		if($shengyu <0){
			$rt=[
				'code'=>0,
			    'msg'=> '余额不够了',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		// 将变量传入
		$rt=[
			'code'=>1,
		    'msg'=> '转出后还剩'.$shengyu.'余额',
			'data'=>'',
		];
		return $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	// 转账余额
	public function zhuanyue() {
		if (IS_POST) {
			$data = \Phpcmf\Service::L('input')->post('data');
			$mima = $data['a'].$data['b'].$data['c'].$data['d'].$data['e'].$data['f'];
			$mima = (int)$mima;
			$password = dr_safe_password($mima);
			if(!$mima){
				$rt=[
					'code'=>0,
				    'msg'=>'密码不能为空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(md5(md5($password).$this->member['zhifusalt'].md5($password)) != $this->member['zhifumima']){
				$rt=[
					'code'=>0,
				    'msg'=>'支付密码错误',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['uid']){
				$rt=[
					'code'=>0,
				    'msg'=>'对方UID不能为空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['zhang']){
				$rt=[
					'code'=>0,
				    'msg'=>'转账'.SITE_SCORE.'不能位空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['beizhu']){
				$rt=[
					'code'=>0,
				    'msg'=>'备注不能位空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			$zhang=(int)$data['zhang'];
			$shengyu = (int)$this->member['money']-$zhang;
			if($zhang > $this->member['money']){
				$rt=[
					'code'=>0,
				    'msg'=> '余额不够了',
					'data'=>$shengyu,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if($shengyu <0){
				$rt=[
					'code'=>0,
				    'msg'=> '余额不够了',
					'data'=>$shengyu,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			/*if($data['uid'] == $this->uid){
				$rt=[
					'code'=>0,
				    'msg'=>'不能给自己转账',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			} */
			//对方uid
			$userweixins=\Phpcmf\Service::M()->db->table('member_oauth')->where('uid', $data['uid'])->get()->getRowArray();
			$users=dr_member_info($data['uid']);
			if ($userweixins['nickname']){
				$usermc = $userweixins['nickname'];
			} elseif ($users['name']) {
				$usermc = '<a href="/index.php?s=hy&c=show&uid='.$data['uid'].'">'.$users['name'].'</a>';
			} else {
				$usermc = '<a href="/index.php?s=hy&c=show&uid='.$data['uid'].'">'.$users['username'].'</a>';
			}
			//转账uid
			$userweixinda=\Phpcmf\Service::M()->db->table('member_oauth')->where('uid', $this->uid)->get()->getRowArray();
			$userda=dr_member_info($this->uid);
			if ($userweixinda['nickname']){
				$userda = $userweixinda['nickname'];
			} elseif ($userda['name']) {
				$userda = '<a href="/index.php?s=hy&c=show&uid='.$this->uid.'">'.$userda['name'].'</a>';
			} else {
				$userda = '<a href="/index.php?s=hy&c=show&uid='.$this->uid.'">'.$userda['username'].'</a>';
			}
			$money = (int)$data['zhang'];
			if($data){
				// 扣转账者的积分
				\Phpcmf\Service::M('member')->add_money($this->uid, -$money);
				\Phpcmf\Service::M('Pay')->add_paylog([
				    'uid' => $this->uid,
				    'username' => "",
				    'touid' => $data['uid'],
				    'tousername' => '',
				    'mid' => 'system', // 特征字符串，system表示系统
				    'title' => $userda.' 向 '.$usermc.' 转 '.$money.' 元 ('.$data['beizhu'].')',
				    'value' => -$money, // 交易金额，正数表示增加金额，负数表示消费金额
				    'type' => 'finecms', // 支付方式，alipy，weixin，finecms表示余额
				    'status' => 1, // 1表示交易成功,0表示未成功
				    'result' => $data['beizhu'],
				    'paytime' => SYS_TIME, // 付款时间，默认当前时间
				    'inputtime' => SYS_TIME, // 流水参生时间，默认当前时间
				]);
				
				// 增加对方UID积分到
				\Phpcmf\Service::M('member')->add_money($data['uid'], $money);
				\Phpcmf\Service::M('Pay')->add_paylog([
				    'uid' => $data['uid'],
				    'username' => "",
				    'touid' => $this->uid,
				    'tousername' => '',
				    'mid' => 'system', // 特征字符串，system表示系统
				    'title' => $userda.' 向您转 '.$money.' 元 ('.$data['beizhu'].')',
				    'value' => $money, // 交易金额，正数表示增加金额，负数表示消费金额
				    'type' => 'finecms', // 支付方式，alipy，weixin，finecms表示余额
				    'status' => 1, // 1表示交易成功,0表示未成功
				    'result' => $data['beizhu'],
				    'paytime' => SYS_TIME, // 付款时间，默认当前时间
				    'inputtime' => SYS_TIME, // 流水参生时间，默认当前时间
				]);
				//通知对方
				$dataim = [
				 'catid'=> 8, //类型
				 'title' => '余额转账', //标题
				 'zhiding' => '', //置顶
				 'content'=> $userda.' 向您转 '.$money.' 元', //通知内容
				 'uid'=> $this->uid, //发布人的uid
				 'faxinren'=> $this->uid, //发布人的uid
				 'shouxinren'=> (int)$data['uid'],//收信人
				 'tupian'=> '', //图片
				 'shipin'=> '', //视频
				 'yuyin'=> '', //语音
				 'fujian'=> '', //附件
				 'yidu'=> 0, //已读
				 'quanziid'=> '', //圈子ID
				 'quantieid'=> '', //圈帖ID
				 'url' => '',
				];
				\Phpcmf\Service::M('auth')->addtongzhi($dataim);
				$rt=[
					'code'=>1,
				    'msg'=>SITE_SCORE.'转账成功',
					'data'=>$data,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			} else {
				$rt=[
					'code'=>0,
				    'msg'=>SITE_SCORE.'转账数据为空',
					'data'=>$data,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
				//$this->_msg(1, dr_lang('转账成功'), dr_url_prefix($url));
			}
			
		} else {
			$rt=[
				'code'=>0,
			    'msg'=>SITE_SCORE.'转账参数错误',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		
		//\Phpcmf\Service::V()->display('jifen-shouru.html');
	}
	//余额提现
	public function tixianyue(){
		if (IS_POST) {
			$data = \Phpcmf\Service::L('input')->post('data');
			$mima = $data['a'].$data['b'].$data['c'].$data['d'].$data['e'].$data['f'];
			$mima = (int)$mima;
			$password = dr_safe_password($mima);
			if(!$mima){
				$rt=[
					'code'=>0,
				    'msg'=>'密码不能为空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(md5(md5($password).$this->member['zhifusalt'].md5($password)) != $this->member['zhifumima']){
				$rt=[
					'code'=>0,
				    'msg'=>'支付密码错误',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			
			if(!$data['zhang']){
				$rt=[
					'code'=>0,
				    'msg'=>'转账'.SITE_SCORE.'不能位空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['beizhu']){
				$rt=[
					'code'=>0,
				    'msg'=>'备注不能位空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			$zhang=(int)$data['zhang'];
			$shengyu = (int)$this->member['money']-$zhang;
			if($zhang > $this->member['money']){
				$rt=[
					'code'=>0,
				    'msg'=> '余额不够了',
					'data'=>$shengyu,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if($shengyu <0){
				$rt=[
					'code'=>0,
				    'msg'=> '余额不够了',
					'data'=>$shengyu,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			//转账uid
			$userweixinda=\Phpcmf\Service::M()->db->table('member_oauth')->where('uid', $this->uid)->get()->getRowArray();
			$userda=dr_member_info($this->uid);
			if ($userweixinda['nickname']){
				$userda = $userweixinda['nickname'];
			} elseif ($userda['name']) {
				$userda = '<a href="/index.php?s=hy&c=show&uid='.$this->uid.'">'.$userda['name'].'</a>';
			} else {
				$userda = '<a href="/index.php?s=hy&c=show&uid='.$this->uid.'">'.$userda['username'].'</a>';
			}
			\Phpcmf\Service::M('member')->add_money($this->uid, -$zhang);
			\Phpcmf\Service::M('Pay')->add_paylog([
			    'uid' => $this->uid,
			    'username' => "",
			    'touid' => 1,
			    'tousername' => '',
			    'mid' => 'system', // 特征字符串，system表示系统
			    'title' => $userda.' 提现 '.$zhang.' 元 ('.$data['beizhu'].')',
			    'value' => -$zhang, // 交易金额，正数表示增加金额，负数表示消费金额
			    'type' => 'finecms', // 支付方式，alipy，weixin，finecms表示余额
			    'status' => 1, // 1表示交易成功,0表示未成功
			    'result' => $data['beizhu'],
			    'paytime' => SYS_TIME, // 付款时间，默认当前时间
			    'inputtime' => SYS_TIME, // 流水参生时间，默认当前时间
			]);
			$tixianhao = \Phpcmf\Service::M()->db->table('1_quan_tixian_hao')->where('uid', $this->uid)->get()->getRowArray();
			// 提现记录
			\Phpcmf\Service::M()->db->table('1_quan_tixian')->insert(array(
			    'cid' => '',
			    'uid' => $this->uid,
			    'money' => $zhang,
			    'leixing' => $tixianhao['leixing'],
				'erweima' => $tixianhao['erweima'],
				'pingzheng' => '',
				'moren' => '',
				'tixianming' => $tixianhao['tixianming'],
				'tixianhao' => $tixianhao['tixianhao'],
				'zhuangtai' => '0',
				'inputtime' => SYS_TIME,
				'endtime' => 0,
			));
			$rt=[
				'code'=>1,
			    'msg'=>'提现成功',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		$rt=[
			'code'=>0,
		    'msg'=>'提现参数错误',
			'data'=>$data,
		];
		return $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	// 提现单
	public function tixiandan() {
	
		$meta_title = '提现单';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('qianbao-tixiandan.html');
	}
	// 已购买
	public function yigoumai() {
	
		$meta_title = '已购买';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('yigoumai.html');
	}
	// 积分
	public function jifen() {
	
		$meta_title = '我的'.SITE_SCORE;
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    //'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('jifen.html');
	}
	// 支出积分
	public function zhichujifen() {
	
		$meta_title = '我的'.SITE_SCORE.'消费支出';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    //'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('jifen-zhichu.html');
	}
	// 收入积分
	public function shourujifen() {
	
		$meta_title = '我的'.SITE_SCORE.'消费收入';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    //'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('jifen-shouru.html');
	}
	// 转账积分
	public function zhuanjifen() {
		if (IS_POST) {
			$data = \Phpcmf\Service::L('input')->post('data');
			$mima = $data['a'].$data['b'].$data['c'].$data['d'].$data['e'].$data['f'];
			$mima = (int)$mima;
			$password = dr_safe_password($mima);
			if(!$mima){
				$rt=[
					'code'=>0,
				    'msg'=>'密码不能为空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(md5(md5($password).$this->member['zhifusalt'].md5($password)) != $this->member['zhifumima']){
				$rt=[
					'code'=>0,
				    'msg'=>'支付密码错误',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['uid']){
				$rt=[
					'code'=>0,
				    'msg'=>'对方UID不能为空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['zhang']){
				$rt=[
					'code'=>0,
				    'msg'=>'转账'.SITE_SCORE.'不能位空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if(!$data['beizhu']){
				$rt=[
					'code'=>0,
				    'msg'=>'备注不能位空',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			$zhang=(int)$data['zhang'];
			$shengyu = (int)$this->member['score']-$zhang;
			if($zhang > $this->member['score']){
				$rt=[
					'code'=>0,
				    'msg'=> SITE_SCORE.'不够了',
					'data'=>$data,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			if($shengyu <0){
				$rt=[
					'code'=>0,
				    'msg'=> SITE_SCORE.'不够了',
					'data'=>$data,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			}
			/*if($data['uid'] == $this->uid){
				$rt=[
					'code'=>0,
				    'msg'=>'不能给自己转账',
					'data'=>'',
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			} */
			//对方uid
			$userweixins=\Phpcmf\Service::M()->db->table('member_oauth')->where('uid', $data['uid'])->get()->getRowArray();
			$users=dr_member_info($data['uid']);
			if ($userweixins['nickname']){
				$usermc = $userweixins['nickname'];
			} elseif ($users['name']) {
				$usermc = '<a href="/index.php?s=hy&c=show&uid='.$data['uid'].'">'.$users['name'].'</a>';
			} else {
				$usermc = '<a href="/index.php?s=hy&c=show&uid='.$data['uid'].'">'.$users['username'].'</a>';
			}
			//转账uid
			$userweixinda=\Phpcmf\Service::M()->db->table('member_oauth')->where('uid', $this->uid)->get()->getRowArray();
			$userda=dr_member_info($this->uid);
			if ($userweixinda['nickname']){
				$userda = $userweixinda['nickname'];
			} elseif ($userda['name']) {
				$userda = '<a href="/index.php?s=hy&c=show&uid='.$this->uid.'">'.$userda['name'].'</a>';
			} else {
				$userda = '<a href="/index.php?s=hy&c=show&uid='.$this->uid.'">'.$userda['username'].'</a>';
			}
			$money = (int)$data['zhang'];
			if($data){
				// 扣转账者的积分
				\Phpcmf\Service::M('member')->add_score($this->uid, -$money, ' 您向 ' .$usermc. ' 转 '.$money.''.SITE_SCORE.' 备注：'.$data['beizhu']);
				// 增加对方UID积分到
				\Phpcmf\Service::M('member')->add_score($data['uid'], $money, $userda.' 向您转 '.$money.''.SITE_SCORE);
				//通知对方
				$dataim = [
				 'catid'=> 8, //类型
				 'title' => '转账'.SITE_SCORE, //标题
				 'zhiding' => '', //置顶
				 'content'=> $userda.' 向您转 '.$money.''.SITE_SCORE, //通知内容
				 'uid'=> $this->uid, //发布人的uid
				 'faxinren'=> $this->uid, //发布人的uid
				 'shouxinren'=> (int)$data['uid'],//收信人
				 'tupian'=> '', //图片
				 'shipin'=> '', //视频
				 'yuyin'=> '', //语音
				 'fujian'=> '', //附件
				 'yidu'=> 0, //已读
				 'quanziid'=> '', //圈子ID
				 'quantieid'=> '', //圈帖ID
				 'url' => '',
				];
				\Phpcmf\Service::M('auth')->addtongzhi($dataim);
				$rt=[
					'code'=>1,
				    'msg'=>SITE_SCORE.'转账成功',
					'data'=>$data,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
			} else {
				$rt=[
					'code'=>0,
				    'msg'=>SITE_SCORE.'转账数据为空',
					'data'=>$data,
				];
				return $this->_json($rt['code'], $rt['msg'], $rt['data']);
				//$this->_msg(1, dr_lang('转账成功'), dr_url_prefix($url));
			}
			
		} else {
			$rt=[
				'code'=>0,
			    'msg'=>SITE_SCORE.'转账参数错误',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		
		//\Phpcmf\Service::V()->display('jifen-shouru.html');
	}
	// 转账积分
	public function zhuanuid() {
	    $uid = (int)\Phpcmf\Service::L('input')->get('uid');
		
		// 将变量传入
		$user=dr_member_info($uid);
		$touxiang=dr_avatar($uid);
		if (!$user){
			$rt=[
				'code'=>0,
			    'msg'=>'没有这位用户',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		$data=[
			'uid'=>$uid,
			'touxiang'=>$touxiang,
			'name'=>$user['username'],
		];
		$rt=[
			'code'=>1,
		    'msg'=>'',
			'data'=>$data,
		];
		return $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	// 积分判断
	public function jifenpanduan() {
	    $jifen = (int)\Phpcmf\Service::L('input')->get('jifen');
		$shengyu = $this->member['score']-$jifen;
		if($jifen > $this->member['score']){
			$rt=[
				'code'=>0,
			    'msg'=> SITE_SCORE.'不够了',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		if($shengyu <0){
			$rt=[
				'code'=>0,
			    'msg'=> SITE_SCORE.'不够了',
				'data'=>$data,
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		// 将变量传入
		$rt=[
			'code'=>1,
		    'msg'=> '转出后还剩'.$shengyu.SITE_SCORE.'',
			'data'=>'',
		];
		return $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}
	public function zhifumima() {
		$mima = (int)\Phpcmf\Service::L('input')->get('mima');
		$password = dr_safe_password($mima);
		if(!$mima){
			$rt=[
				'code'=>0,
			    'msg'=>'支付密码不能为空',
				'data'=>'',
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		if(md5(md5($password).$this->member['zhifusalt'].md5($password)) != $this->member['zhifumima']){
			$rt=[
				'code'=>0,
			    'msg'=>'支付密码错误',
				'data'=>'',
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		} else {
			$rt=[
				'code'=>1,
			    'msg'=>'支付密码正确',
				'data'=>'',
			];
			return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		}
		
	}
	// 经验
	public function jingyan() {
	
		$meta_title = '我的经验';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('jingyan.html');
	}
	// 粉丝
	public function fensi() {
	
		$meta_title = '我的粉丝';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('fensi.html');
	}
	// 关注
	public function guanzhu() {
	
		$meta_title = '我的关注';
		// 将变量传入模板
		\Phpcmf\Service::V()->assign([
		    'p' => $p,
		    'stype' => $stype,
		    'sname' => strlen($tid) ? $stype[$tid] : '全部',
			'meta_title' => $meta_title,
		]);
		
		\Phpcmf\Service::V()->display('guanzhu.html');
	}
	// 删除加入到圈子
	public function zhudel() {
		//删除
		
		$id = intval(\Phpcmf\Service::L('Input')->get('id'));
		$cid = intval(\Phpcmf\Service::L('Input')->get('cid'));
		
		if (!$id) {
			$this->_msg(0, 'id不能为空'.$id.'-'.$this->uid);
		}
		if (!$cid) {
			$this->_msg(0, 'id不能为空'.$id.'-'.$this->uid);
		}
		$quanid = \Phpcmf\Service::M()->db->table('1_quan')->where('id', $cid)->where('uid', $this->uid)->get()->getRowArray();
		// 删除帖子
		if (!$quanid) {
			$jiaru = \Phpcmf\Service::M()->db->table('1_quan_cart')->where('id', $id)->where('cid', $cid)->where('uid', $this->uid)->get()->getRowArray();
			if (!$jiaru) {
				$this->_msg(0, '没有这个圈子');
			}
			\Phpcmf\Service::M()->table('1_quan_cart')->where('id', $id)->delete();
		} else {
			$this->_msg(0, '没有这个圈子');
		}
		//
		$this->_msg(1, '退出成功');
	
	
	}

}
